package com.dragon.logical.service.avttendance.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dragon.logical.service.avttendance.IAttendanceReplaceService;
import com.dragon.repository.entity.AttendanceReplace;
import com.dragon.repository.mapper.AttendanceMapper;
import com.dragon.repository.mapper.AttendanceReplaceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 补卡表 服务实现类
 * </p>
 *
 * @author sy
 * @since 2023-08-15
 */
@Service
public class AttendanceReplaceServiceImpl extends ServiceImpl<AttendanceReplaceMapper, AttendanceReplace> implements IAttendanceReplaceService {

    @Autowired
    AttendanceReplaceMapper replaceMapper;
    @Autowired
    AttendanceMapper attendanceMapper;

    @Override
    public Page<AttendanceReplace> replaceList(Integer adminId, Integer page, Integer limit) {
        Page<AttendanceReplace> replacePage = new Page<>(page, limit);
        QueryWrapper<AttendanceReplace> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .eq(adminId != null ,AttendanceReplace::getAdminId,adminId);
        Page<AttendanceReplace> attendanceReplacePage = replaceMapper.selectReplacePage(replacePage, wrapper);
        return attendanceReplacePage;
    }

    @Override
    public void addReplace(AttendanceReplace replace) {
        //获取补卡时间的考勤信息
        //                                                                                                                                                       attendanceMapper.selectOne()
        replaceMapper.insert(replace);
    }
}
